import request from '@/utils/request'

/**
 * 为角色分配权限的菜单树
 */
export function getMenusTree() {
  return request({
    url: '/api/admin/menus/tree',
    method: 'get'
  })
}


/**
 * 根据角色id还原它拥有菜单ID
 */
export function ownMenuByRoleId(roleId) {
  return request({
    url: `/api/admin/menus/own/${roleId}`,
    method: 'get'
  })
}

export function buildMenus() {
  return request({
    url: '/api/admin/menus/build',
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: '/api/menus',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: '/api/menus',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: '/api/menus',
    method: 'put',
    data
  })
}
 